<template>
  <div>
    <div class="sale">
      <el-row :gutter="10" :justify="start">
        <el-col :span="6"
          ><div class="grid-content bg-purple">
            <div class="logo">
              <img src="./images/1.png" alt="" />
              <span>年度销售总额</span>
            </div>
            <p>{{ money }}</p>
          </div></el-col
        >
        <el-col :span="6"
          ><div class="grid-content bg-purple">
            <div class="logo">
              <img src="./images/2.png" alt="" />
              <span>今日销售额</span>
            </div>
            <p>799`639</p>
          </div></el-col
        >
        <el-col :span="6"
          ><div class="grid-content bg-purple">
            <div class="logo">
              <img src="./images/3.png" alt="" />
              <span>本周销售额</span>
            </div>
            <p>799`639</p>
          </div></el-col
        >
        <el-col :span="6"
          ><div class="grid-content bg-purple">
            <div class="logo">
              <img src="./images/4.png" alt="" />
              <span>本月销售额</span>
            </div>
            <p>799`639</p>
          </div></el-col
        >
      </el-row>
    </div>
    <div class="saleData">
      <div class="saleTable">
        <div id="box"></div>
        <tables />
      </div>
      <div class="saleMoney">
        <saled @sm="snum" />
      </div>
    </div>
  </div>
</template>

<script>
import * as echarts from "echarts";
import { ElRow, ElCol } from "element-plus";
import { onMounted } from "vue";
import tables from "./components/table.vue";
import saled from "./components/saled.vue";

export default {
  components: {
    ElRow,
    ElCol,
    tables,
    saled,
  },
  setup() {
    onMounted(() => {
      var myChart = echarts.init(document.getElementById("box", "table"));

      myChart.setOption({
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#6a7985",
            },
          },
        },

        grid: {
          left: "3%",
          right: "4%",
          bottom: "10%",
          containLabel: true,
        },
        xAxis: [
          {
            type: "category",
            boundaryGap: false,
            data: [
              "1月",
              "2月",
              "3月",
              "4月",
              "5月",
              "6月",
              "7月",
              "8月",
              "9月",
              "10月",
              "11月",
              "12月",
            ],
          },
        ],
        yAxis: [
          {
            type: "value",
          },
        ],
        series: [
          {
            name: "Email",
            type: "line",
            stack: "Total",
            areaStyle: {},
            emphasis: {
              focus: "series",
            },
            data: [
              20000, 21000, 20500, 23000, 19000, 21000, 20000, 25000, 30000,
              19000, 30000, 35000,
            ],
          },
          {
            name: "Union Ads",
            type: "line",
            stack: "Total",
            areaStyle: {},
            emphasis: {
              focus: "series",
            },
            data: [
              30000, 32000, 30500, 33000, 29000, 31000, 30000, 35000, 40000,
              29000, 40000, 45000,
            ],
          },
        ],
      });
    });
  },
  methods: {
    snum(money) {
      // console.log(money);
      this.money = money;
    },
  },
  data() {
    return {
      money: 0,
    };
  },
};
</script>

<style lang="less" scoped>
.el-row {
  margin-bottom: 20px;
}
.el-row:last-child {
  margin-bottom: 0;
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  width: 260px;
  height: 120px;
  border-radius: 8px;
  min-height: 36px;
  overflow: hidden;
  text-align: center;
  background: #fff;
  .logo {
    width: 150px;
    height: 40px;
    margin: 20px auto 20px;
    font-size: 16px;
    line-height: 50px;
    display: flex;
    justify-content: space-between;
  }
  p {
    font-size: 20px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    color: #333333;
  }
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
.saleData {
  display: flex;
  justify-content: space-between;
  .saleTable {
    width: 550px;
    height: 390px;

    margin-top: 10px;
    border-radius: 8px;
    #box {
      width: 100%;
      height: 190px;
      border-radius: 8px;
      background: #fff;
      margin-bottom: 10px;
    }
  }
  .saleMoney {
    width: 580px;
    height: 390px;
    margin-top: 10px;
    border-radius: 8px;
  }
}
</style>
